# Contributor: David Demelier <markand@malikania.fr>
# Maintainer: David Demelier <markand@malikania.fr>
pkgname=libretro-picodrive
pkgver=0_git20220405
pkgrel=0
_commit="bb6a52fe60e6f3bdcd17effe75e68fd0f8c44ba7"
_commit_dr_libs="1e42667b0912437d1c101a59ee9d0225ba0dffb5"
_commit_libchdr="a03e69319164f69d781ab8e453f8cf407387bd13"
_commit_emu2413="4062e93e9316ee5c488167ade5a83753e5f07ae3"
pkgdesc="fast MegaDrive/MegaCD/32X emulator"
url="https://github.com/libretro/picodrive"
arch="all !ppc64le !s390x !riscv64"
license="custom"
source="$pkgname-$_commit.tar.gz::https://github.com/libretro/picodrive/archive/$_commit.tar.gz
	$pkgname-dr_libs-$_commit_dr_libs.tar.gz::https://github.com/mackron/dr_libs/archive/$_commit_dr_libs.tar.gz
	$pkgname-libchdr-$_commit_libchdr.tar.gz::https://github.com/rtissera/libchdr/archive/$_commit_libchdr.tar.gz
	$pkgname-emu2413-$_commit_emu2413.tar.gz::https://github.com/digital-sound-antiques/emu2413/archive/$_commit_emu2413.tar.gz"
builddir="$srcdir/picodrive-$_commit"
options="!check" # No tests

prepare()
{
	default_prepare
	rm -rf platform/common/dr_libs && mv "$srcdir/dr_libs-$_commit_dr_libs" platform/common/dr_libs
	rm -rf pico/cd/libchdr && mv "$srcdir/libchdr-$_commit_libchdr" pico/cd/libchdr
	rm -rf pico/sound/emu2413 && mv "$srcdir/emu2413-$_commit_emu2413" pico/sound/emu2413
}

build() {
	make -f Makefile.libretro
}

package() {
	install -Dm644 picodrive_libretro.so "$pkgdir"/usr/lib/libretro/picodrive_libretro.so
}

sha512sums="
505cb28d74944093d04474846e74aa5135058ead836b004a9250f18f53bf8aef239986e3e88ae3ac33879447757bc4d0671ef42661843b1a4d1349ad434b986d  libretro-picodrive-bb6a52fe60e6f3bdcd17effe75e68fd0f8c44ba7.tar.gz
640ac3d0b2a3e47f47e1a2db1a0b3f6df65bc91e476b722e355c417f14f98eff97c878553252ba6877ff98bcd35056c185c66ddd394bf31cc33400b480dd415b  libretro-picodrive-dr_libs-1e42667b0912437d1c101a59ee9d0225ba0dffb5.tar.gz
407b1b310126e223b596ef99b7cbf0baadc06c3cb84e3173a40a2ddcf3b994e86e420fdafd814f11a7d0ac2c9feea30c28ff9ece6834d5f317064185546d4101  libretro-picodrive-libchdr-a03e69319164f69d781ab8e453f8cf407387bd13.tar.gz
ae75d43973c4d3c8204609a52dd18d1c84ce7962af5219d7f34a3b7313268168adf0bd556771487aa0d2d1e382fe18b0b98ba055ef7ff0109f74adbdb1b913f4  libretro-picodrive-emu2413-4062e93e9316ee5c488167ade5a83753e5f07ae3.tar.gz
"
